package com.jfire.json.serializer;

import java.lang.reflect.Type;
import com.jfire.baseutil.collection.ObjectCollect;
import com.jfire.baseutil.collection.StringCache;
import com.jfire.json.field.JsonField;
import com.jfire.json.util.JsonConfig;
import com.jfire.json.util.JsonSerializer;

public class ObjectSerializer implements JsonSerializer
{
    
    @Override
    public Object transToJsonvalue(Object src, ObjectCollect collect)
    {
        return JsonConfig.getSerializer(src.getClass()).transToJsonvalue(src, collect);
    }
    
    @Override
    public void setJsonFields(JsonField[] jsonFields)
    {
        // TODO Auto-generated method stub
        
    }
    
    @Override
    public void writeToString(StringCache cache, Object value, ObjectCollect collect)
    {
        if (value != null)
        {
            JsonConfig.getSerializer(value.getClass()).writeToString(cache, value, collect);
        }
    }
    
    @Override
    public Object toBean(Object value, Type type)
    {
        return value;
    }
    
}
